package com.zw.a.basic.a08.demo03_string;

//案例: 演示String创建对象的特点.
public class StringDemo02 {
    public static void main(String[] args) {
        //1.定义字符数组chs, 初始化值为: 'a, 'b', 'c', 这三个字符 .
        char[] chs = {'a', 'b', 'c'};
        //2.将其分别封装成s1, s2这两个字符串对象.
        String s1 = new String(chs);
        String s2 = new String(chs);
        //3.通过==判断s1和s2这两个字符串对象是否相同.
        System.out.println(s1 == s2);               //false
        System.out.println("-----------------------------------");

        //4.直接通过""的方式创建两个字符串对象s3和s4.
        String s3 = "abc";
        String s4 = "abc";
        //5.通过==判断s3和s4这两个字符串对象是否相同.
        System.out.println(s3 == s4);               //true
        System.out.println(s3 == s1);               //false
    }
}
